
//环形图表
var width = 306,
    height = 306,
    radius = 153,
    innerRadius = 122,
    colors = d3.scale.category10();

var pieData = [
    {label: "part one",
        value: 10},
    {label: "part two",
        value: 50},
    {label: "part three",
        value: 15},
    /*{label: "part four",
        value: 50},
    {label: "part five",
        value: 80},
    {label: "part six",
        value: 50},
    {label: "part five",
        value: 50},
    {label: "part six",
        value: 50}*/
]

var pie = d3.layout.pie()
    .value(function(d) {
        return d.value;
    })

var arc = d3.svg.arc()
    .outerRadius(radius)
    .innerRadius(innerRadius)

var myChart=d3.select('#chart').append('svg')
    .attr('width', width)
    .attr('height', height)
    .append('g')
    .attr('transform', 'translate('+(width-radius)+', '+(height-radius)+')')
    .selectAll('path').data(pie(pieData))
    .enter().append('g')
    .attr('class', 'slice')
    .transition()
    .ease("exp")
    .duration(2000)

var slices = d3.selectAll('g.slice')
    .append('path')
    .attr('fill', function(d,i) {
        return colors(i);
    } )
    .attr('d', arc)
    .transition()
    .ease("elastic")
    .duration(2000)
    .attrTween("d", tweenPie);

function tweenPie(b) {
    var i = d3.interpolate({startAngle: 1.1*Math.PI, endAngle: 1.1*Math.PI}, b);
    return function(t) { return arc(i(t)); };
}




$(function () {
    //切换tab
    $(".member-bar").on("click","li",function (){
        var index = $(this).index();
        console.log(index);
        $(this).addClass("select").siblings("li").removeClass("select");
        $(".member-tab-box ul").eq(index).removeClass("none").siblings().addClass("none");
    });
    //点击回到顶部
    $("#return-top").unbind().on("click", function() {
        $('body,html').animate({
            scrollTop: 0
        }, 500);
        $(this).fadeOut(200);
        return false;
    });
    //绑定滚动条事件
    //绑定滚动条事件
    var obj = document.getElementById("js-member-bar");
    var top = getTop(obj);
    var isIE6 = /msie 6/i.test(navigator.userAgent);
    window.onscroll = function(){
        var bodyScrollTop = document                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        .documentElement.scrollTop || document.body.scrollTop;
        if (bodyScrollTop > top){
        obj.style.position = (isIE6) ? "absolute" : "fixed";
        obj.style.top = (isIE6) ? bodyScrollTop + "px" : "0px";
        } else {
        obj.style.position = "static";
        }
    }
    function getTop(e){
        var offset = e.offsetTop;
        if(e.offsetParent != null) offset += getTop(e.offsetParent);
        return offset;
    }
})



















